from ...math.mathematic import e as _e
from math import log


endl: str = '\n'
EOF: int = -1
NULL: int = 0
long, double, char, string = int, float, str, str
fabs = abs
true: bool = True
false: bool = False


def printf(form: str, *args) -> int:
    """模仿c语言stdio.h里的printf"""
    temp = sprintf(form, *args)
    print(temp, end='')
    return len(temp)


def sprintf(form: str, *args) -> str:
    """模仿c语言stdio.h里的sprintf"""
    return form % args


def putchar(ch: str) -> str:
    """模仿c语言stdio.h里的putchar"""
    print("%c" % ch, end='')
    return ch


def getchar() -> str:
    """模仿c语言stdio.h里的getchar"""
    temp = input()
    return temp[0] if len(temp) else EOF


class Cout:
    """模仿C语言iostream里的cout"""

    def __lshift__(self, other):
        print(other, end='')
        return self


cout: Cout = Cout()


def sqrt(x: float) -> float:
    """模仿c语言math.h里的sqrt\n
    平方根函数"""
    return x ** 0.5


def exp(x: float) -> float:
    """模仿c语言math.h里的exp\n
    指数函数"""
    return _e ** x


class switch:
    """模仿c语言里的switch语句"""

    def __init__(self, *value) -> None:
        self.value: tuple = value
        self.drop: bool = false

    def __iter__(self):
        for value in self.value:
            self.drop = false
            yield self.case(value)

    def case(self, value):
        def match(*args) -> bool:
            if not self.drop and not args:
                return true
            elif value in args:
                self.drop = true
                return true
            else:
                return false

        return match


def sizeof(item) -> int:
    return item.__sizeof__()
